package com.jvm123

/**
 *
 * @author yawn
 * @date 2020/12/18 星期五
 *
 */

// 代码块
def num = 0
def clos = {++num}
clos.call()
println num

// 返回结果
def clos2 = { return ++it}
println clos2(128)

// 闭包用于遍历
def arrs = [1, 2, 3, 4, 5, 6]
arrs.each { println(it) }
arrs.each { item -> println(item) }

def map = ["id": 1, "name": "yawn", "age": 18]
map.each { println it }


